<?php
class Person {
    private $name = '张三';
    protected $age = 30;

    public function __get($name)
    {
        return $this->$name;
    }

    public function __set($name, $value)
    {
        $this->$name = $value;
    }

    public function __toString()
    {
        return '对象可以用var_dump打印，不能echo';
    }

    public function __call($name, $arguments)
    {
        echo '方法' . $name . '不存在';
    }
}

$p = new Person();
$s_p = serialize($p);
$rs_p = unserialize($s_p);
$rs_p->test();
var_dump($rs_p);